

<%@page import="cs4280.dao.MovieDAO"%>
<%--
    Document   : index
    Created on : 2011-3-22, 11:19:34
    Author     : PangPei
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.util.ArrayList, java.util.Iterator, cs4280.bean.*"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <title>Cult Cinema</title>
        <meta name="keywords" content="" />
        <meta name="description" content="This web site exists to fulfill the coursework requirement of CS4280.
              Do not use your real personal data as input." />
        <link href="default.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="jquery/jquery-1.4.2.min.js"></script>
        <script type="text/javascript" src="jquery/jquery.slidertron-0.1.js"></script>
        <script type="text/javascript" src="jquery.twitter.js"></script>
        <link rel="stylesheet" href="jquery.twitter.css" type="text/css" media="all"/>
        <style type="text/css">

            @import "gallery.css";

        </style>


    </head>
    <body><div id="wrapper">
            <div id="header">
                <div id="logo">
                    <h1><a href="#">CultCinema </a></h1>
                    <h2><a href="#">By Phoena and Yvonne</a></h2>
                </div>

                <!-- end div#logo -->

                <div id="menu">
                    <ul>
                        <form name="home" id="home" method="post" action="index.do">
                            <li ><a onclick="home.submit();" >Homepage</a></li>
                        </form>
                        <li class="active"><a href="#" >Movies</a></li>

                        <form name="discuss" id="discuss" method="post" action="/assignmentCinema/">
                            <input type="hidden" name="todo" id="todo" value="messageBox" />
                            <li><a onclick="discuss.submit();">Discuss</a></li>
                        </form>
                        <form name="manage" id="manage" method="post" action="memberControl.do">
                            <li><a onclick="manage.submit();">Manage</a></li>
                        </form>
                    </ul>
                </div>

                <!-- end div#menu -->

            </div>
        </div>

        <div>
            <div id="page">
                <div id="page-bgtop">
                    <div id="content">
                        <div id="gallery-bg">
                            <div id="gallery-bgtop">
                                <div id="gallery-bgbtm">
                                    <div id="foobar">
                                        <div class="navigation"> <a href="#" class="first">[ &lt;&lt; ]</a> &nbsp; <a href="#" class="previous">[ &lt; ]</a> &nbsp; <a href="#" class="next">[ &gt; ]</a> &nbsp; <a href="#" class="last">[ &gt;&gt; ]</a> </div>

                                        <div class="viewer">
                                            <div class="reel">
                                                <div class="slide"> <img src="images/img13.jpg" alt=""> <span>Phoena and Yvonne.</span> </div>
                                                <div class="slide"> <img src="http://www.blog.spoongraphics.co.uk/wp-content/uploads/2011/soldier-character/vector-soldier-character.jpg" alt=""> <span>Phoena.</span> </div>
                                                <div class="slide"> <img src="http://www.blog.spoongraphics.co.uk/wp-content/uploads/2010/reindeer/reindeer-character-sm.jpg" alt=""> <span>Yvonne.</span> </div>
                                                <div class="slide"> <img src="http://www.blog.spoongraphics.co.uk/wp-content/uploads/2009/12/1.png" alt=""> <span>Phoena and Yvonne.</span> </div>
                                            </div>
                                        </div>
                                    </div>
                                    <script type="text/javascript">

                                        $('#foobar').slidertron({
                                            viewerSelector:			'.viewer',
                                            reelSelector:			'.viewer .reel',
                                            slidesSelector:			'.viewer .reel .slide',
                                            navPreviousSelector:	'.previous',
                                            navNextSelector:		'.next',
                                            navFirstSelector:		'.first',
                                            navLastSelector:		'.last'
                                        });
                                    </script>
                                    <!-- end -->

                                </div>
                            </div>
                        </div>
                        <div class="post">
                            <div class="post-bgtop">
                                <div class="post-bgbtm">
                                    <div class="entry">

<%@page import="cs4280.bean.*,java.util.ArrayList,java.util.Iterator" %>

        <style type="text/css">
            table#bookTable { border: 1px solid #000000; }
            table#bookTable col#header { background-color: #777777; color: #000000; }
            table#bookTable col#content { font-size: larger; }
        </style>

        <style type="text/css">

            a {text-decoration:none}
            .tableBorder{border-style:solid none solid solid;border-width:1px;border-color:black }
            .tdBorder{ border-style:none solid none none;border-width:1px;border-color:black }
            .noSeat{  font-family: "Arial terminal","Tahoma","Courier New","Verdana","Arial", "Helvetica", "sans-serif"; font-size: xx-small; font-weight: bold;font-style: normal; color:#000000}
            .ticketAvailable {  text-decoration:none;font-family: "Arial terminal","Tahoma","Courier New","Verdana","Arial", "Helvetica", "sans-serif"; font-size: xx-small; font-style: normal; color:#000000}
            .ticketSold {  text-decoration:none;font-family: "Arial terminal", "Tahoma","Courier New","Verdana","Arial", "Helvetica", "sans-serif"; font-size: xx-small; font-style: normal; font-weight: bold; color:#000000}
            .ticketReserved {  text-decoration:none;font-family: "Arial terminal", "Tahoma","Courier New","Verdana","Arial", "Helvetica", "sans-serif"; font-size: xx-small; font-style: normal; font-weight: bold; color:#000000}
            .ticketHold {  text-decoration:none;font-family: "Arial terminal","Tahoma","Courier New","Verdana","Arial", "Helvetica", "sans-serif"; font-size: xx-small; font-style: normal; font-weight: bold; color:#000000}
            .corridors {  text-decoration:none;font-family: "Arial terminal","Tahoma","Courier New","Verdana","Arial", "Helvetica", "sans-serif"; font-size: xx-small; font-style: normal; font-weight: bold; color:#FFFFFF}
            .ticketNumber{font-size:10pt;color:#FFFFFF}
        </style>

        <script type="text/javascript">
            if (navigator.appName == "Netscape")
            {docTag = document.getElementsByTagName("*");}
            else
            {docTag = document.all;}
            highlightColor = "";
            ticketColor = new Array();
            ticketSelected = new Array();
            indexUsed = new Array();

            ticketAllowNum = 9;

            for (i=0;i<ticketAllowNum;i++)
            {
                ticketColor[i]="";
                ticketSelected[i]="";
                indexUsed[i]=false;
            }

            function overTicket(ticketNumber)
            {

                if (findTicket(ticketNumber) == -1)
                {
                    highlightColor = eval("docTag.Ticket"+ticketNumber).bgColor;
                    eval("docTag.Ticket"+ticketNumber).bgColor = "red";
                }
            }

            function outTicket(ticketNumber)
            {
                if (findTicket(ticketNumber) == -1)
                {
                    eval("docTag.Ticket"+ticketNumber).bgColor = highlightColor;
                }
            }

            function resetTicket()
            {
                var i;
                for (i=0;i<ticketAllowNum;i++)
                {
                    if (indexUsed[i]==true)
                    {
                        eval("docTag.Ticket"+ticketSelected[i]).bgColor = "#aaaaaa";
                        ticketSelected[i]="";
                        indexUsed[i]=false;
                        //            highlightColor = ticketColor[i];
                    }
                }
            }
            function addTicket(ticketNumber)
            {
                var status=document.getElementById("bookStatus"+ticketNumber).value;
                if (status==0)
                {
                    foundTicket = findTicket(ticketNumber);

                    if (!(foundTicket == -1)) {
                        resetTicket();
                        highlightColor = eval("docTag.Ticket"+ticketNumber).bgColor;
                    }


                    foundIndex =findFreeIndex();
                    if (foundIndex >=0)
                    {
                        indexUsed[foundIndex]=true;
                        ticketSelected[foundIndex]= ticketNumber;
                        ticketColor[foundIndex]= highlightColor;
                        eval("docTag.Ticket"+ticketNumber).bgColor = "#cccc00";
                    }
                    else
                    {
                        alert("The maximum tickets of each transactions is " + 9+ "!");
                    }
                }
                return false; // added for NOWTV
            }

            function findFreeIndex()
            {
                var i;
                for (i=0;i<ticketAllowNum;i++)
                {
                    if (indexUsed[i]==false)
                        return i;
                }
                return -1;
            }

            function findTicket(ticketNumber)
            {
                var i;
                for (i=0;i<ticketAllowNum;i++)
                {
                    if (ticketSelected[i]==ticketNumber)
                    {
                        return i;
                    }
                }
                return -1;
            }


            function addTkt()
            {
            }
        </script>
        <script type="text/javascript">
            function bookTicket() {
                ticketBook="";
                number=0;
                for(i=0;i<ticketAllowNum;i++)
                {
                    if (indexUsed[i]!=false){
                        number++;
                        ticketBook+=ticketSelected[i]+",";
                    }
                }
            }
            function doBook() {
                bookTicket();
                document.getElementById("tickets").value=ticketBook;
                document.getElementById("number").value=number;
                document.getElementById("fmBooking").submit();
            }
        </script>


        <h1>Ticket booking</h1>
        <jsp:useBean id="movie" type="cs4280.bean.Movie" scope="request" />
        <jsp:useBean id="house"type="cs4280.bean.House" scope="request" />
        <p>
        <span>Movie: <%=movie.getName()%></span>

        <jsp:useBean id="screening" type="cs4280.bean.Screening" scope="request"/>
        <span>Time: <%=screening.getShowtime()%> | House:<%=String.valueOf(screening.getHouseid())%> </span>
        <span>Price: <%=screening.getPrice()%></span>
        </p>
        <img alt="seat color indication"  src="images/seatColor.png"/>
        <form id="fmBooking" name="fmBooking" method="post" action="<jsp:expression>(String) request.getAttribute("javax.servlet.forward.request_uri")</jsp:expression>">
            <input type="hidden" name="todo" id="todo" value="doPay" />
            <input type="hidden" name="number" id="number" value="" />
            <input type="hidden" name="tickets" id="tickets" value="" />
            <input type="hidden" name="screeningid" id="screeningid" value="<%=screening.getId()%>"/>

            <table class="tableBorder" id="bookTable" border='0' cellspacing='0' cellpadding='1'>
                <%
                            int col = house.getColnumber();
                            int row = house.getRownumber();
                            ArrayList<Seating> seatings = (ArrayList<Seating>) request.getAttribute("seatings");
                            Iterator<Seating> it = seatings.iterator();
                            for (int i = 0; i < row; i++) {
                %>
                <tr  >
                    <% for (int j = 0; j < col; j++) {
                                                        pageContext.setAttribute("seating", (Seating) it.next());%>
                    <jsp:useBean id="seating" type="cs4280.bean.Seating" scope="page" />
                    <td id="Ticket<%=seating.getId()%>" class="tdborder" width="35" height="30" bgcolor="<%=seating.getColor()%>"
                        onmouseover="javascript:overTicket(<%=seating.getId()%>);" onmouseout="javascript:outTicket(<%=seating.getId()%>);"
                        onclick="return addTicket(<%=seating.getId()%>)">
                        <div class="ticketAvailable" align="center" >
                            <a href="javascript:addTkt()"><span class="ticketNumber">&nbsp;<%=seating.getId()%></span></a>
                        </div>
                        <input type="hidden" id="bookStatus<%=seating.getId()%>" value="<%=seating.getStatus()%>" />
                    </td>
                    <% }%>
                </tr>
                <%
                            }
                %>
            </table>
            <br/>

            <input type="submit" name="submit" value="submit" onclick="doBook();"/>
            <input type="submit" name="btnSubmit" value="cancel" onclick="document.getElementById('todo').value='';" />
        </form>

                                    </div>
                                </div>
                            </div>
                        </div>


                    </div>

                    <!-- end div#content -->

                    <jsp:include page="/WEB-INF/jsp/_sidebar.jsp"/>

                    <!-- end div#sidebar -->

                    <div style="clear: both; height: 1px"></div>
                </div>
            </div>
            <!-- end div#page -->

        </div>
        <!-- end div#wrapper -->

        <div id="footer-wrapper">
            <div id="footer">
                <p id="legal">Copyright &copy; 2007 CYPP . All Rights Reserved. Designed by <a href="http://www.freecsstemplates.org/">Free CSS Templates</a>.</p>
                <p id="links"><a href="#">Privacy Policy</a> | <a href="#">Terms of Use</a></p>
            </div>
        </div>

        <!-- end div#footer -->

    </body>
</html>
